import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
  state:{
    banner:null,
    data:{
      tianxieList:null,
    },
    active:"0",
  },
  actions:{
    // 异步数据请求使用 action  
    changeMsgAction({commit},msg){  //context = {commit:commit(){}}  = {commit} 
        commit("changeMsg",msg);  // action 一定提交mutation  通知 mutations 去修改数据 
    }
  },
  mutations:{
    changeMsg(state,payload){
      state.msg = payload;
    },
    changeBanner(state,payload){
      state.banner = payload;
    },
    changeTianxieList(state,payload){
      state.data = {...state.data,tianxieList:payload}
    },
  //   changeActive(state,payload){
  //     state.active = payload;
  // }
  },
  getters:{

  }
})

export default store;
